﻿using ProjectFootball.MVC.Foundation;
using ProjectFootball.MVC.Foundation.Repositories;
using ProjectFootball.MVC.Models.EntityFramework.Entities;
using System.Collections.Generic;
using System.Linq;

namespace ProjectFootball.MVC.Models.RepositoryProviders
{
    public static class LookupCompetitionRepositoryExtensions
    {
        public static IEnumerable<ICodePickerData> GetImportCodePickerData(this IDataRepository<LookupCompetition> lookupCompetitionRepository)
        {
            return lookupCompetitionRepository.All()
                .Select(c => c.Competition)
                .OrderBy(c => c.CompetitionName)
                .AsEnumerable()
                .Select(c =>
                    new GuidCodePicker()
                    {
                        Code = c.Pk,
                        Description = c.CompetitionName
                    });
        }
    }
}